package com.van.service.sys.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.van.entity.account.User;
import com.van.entity.sys.SysLog;
import com.van.mapper.sys.SysLogMapper;
import com.van.service.sys.SysLogService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author VanKa qq:2395073039
 * @date 2021/6/28 10:11
 */
@Service
@DS("bricks")
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements SysLogService {
    @Override
    public SysLog getOneData(QueryWrapper<SysLog> queryWrapper) {
        List<SysLog> list = list(queryWrapper);
        if (list.size() == 1) {
            return list.get(0);
        } else {
            return null;
        }
    }

    @Override
    public boolean addAdminLog(User u, SysLog.Status s, String m) {
        SysLog l = new SysLog();
        l.adminLog(s,m);
        l.setUserName(u.getName());
        l.setUserId(u.getId());
        return save(l);
    }
}
